package org.xjc.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.xjc.utils.JsonUtil;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageParamsDto<T> implements Serializable {

    private Integer current = 1;

    private Integer pageSize = 10;

    private T searchObject;

    /**
     * 方法用于判空
     * @param clazz
     * @return
     */
    public T getSearchObject(Class<T> clazz) {
        return this.searchObject == null ? JsonUtil.parseObject("{}", clazz) : JsonUtil.parseObject(JsonUtil.toJSONString(this.searchObject), clazz);
    }

}